package application.model 
{
	import application.ApplicationFacade;
	import application.model.VO.PhotoAreaVO;
	import org.puremvc.as3.interfaces.IProxy;
	import org.puremvc.as3.patterns.proxy.Proxy;
	/**
	 * ...
	 * @author Ning
	 */
	public class PhotoAreaProxy extends Proxy implements IProxy
	{
		public static const NAME:String = 'PhotoAreaProxy';
		
		private var _dataProxy:DataProxy;
		private var _layoutProxy:LayoutProxy;
		
		public function PhotoAreaProxy() 
		{
			super(NAME,new PhotoAreaVO);
			init();
		}
		private function init():void
		{
			_dataProxy = facade.retrieveProxy(DataProxy.NAME) as DataProxy;
			_layoutProxy = facade.retrieveProxy(LayoutProxy.NAME) as LayoutProxy;
		}
		
		public function setConfig():void
		{
			var configXML:XML = AppGlobal.CONFIG_XML;
			photoAreaVO.layoutPhotoWidth = configXML.photoArea.@['layoutPhotoWidth'];
			photoAreaVO.layoutPhotoHeight = configXML.photoArea.@['layoutPhotoHeight'];
			photoAreaVO.photoWidth = configXML.photoArea.@['photoWidth'];
			photoAreaVO.photoHeight = configXML.photoArea.@['photoHeight'];
			photoAreaVO.layoutVO = _layoutProxy.getLayout(AppGlobal.PHOTO_AREA_LAYOUT_KEY);
			
			sendNotification(ApplicationFacade.UPDATE_PIC_AREA_CONFIG, photoAreaVO);
		}
		public function callPicDataByName(name:String):void
		{
			var data:Array = _dataProxy.getPicDataByGroupName(name);
			sendNotification(ApplicationFacade.UPDATE_PIC_AREA_DATA, data);
		}
		
		private function get photoAreaVO():PhotoAreaVO {
			return  data as PhotoAreaVO;
		}
	}
}